<%@page contentType="text/html" pageEncoding="windows-1252"%>
<%@page import="java.sql.Date"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.SQLException"%>
<%@page import="startup.model.trip.MissionRequest"%>
<%@page import="startup.model.user.Student"%>
<%@page import="startup.utils.DateTool"%>
<%@page import="startup.utils.Query"%>
<%
	try
	{
		Student student = ( Student )session.getAttribute( "currentSessionUser" );
		student.completeAttributesFromWorkingDB();

		MissionRequest toSubmit = new MissionRequest();
		Student a = ( ( Student )session.getAttribute( "currentSessionUser" ) );
		toSubmit.setOwnerStudentId( a.getId() );
		session.setAttribute( "missionRequest", toSubmit );
%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="windows-1252">
        <title>New Mission Request</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <!-- Le styles -->
        <link href="styles/bootstrap.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
    </head>
    <body>
        <!--Barra Superiore-->
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container-fluid">
                    <a class="brand" href="#">Student : <%=student.getSurname()%> <%=student.getName()%> </a>
                    <div class="nav pull-right">
                        <ul class="nav">
                            <li>
                                <form action="Logout" method="post">
                                    <button class="btn btn-primary btn-small">Sign out</button>
                                </form>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!--CONTENUTO GRANDE -->
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3" style="position:fixed;">
                    <div class="well sidebar-nav">
                        <ul class="nav nav-list">
                            <li><a href="javascript:history.back()"><i class="icon-arrow-left"></i> Back</a></li>
                            <li class="nav-header">Location</li>
                            <li><a href="studentChooseHistoryToShow.jsp"><i class="icon-home"></i> Home</a></li>
                            <li><a href="studentActualHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> ACTIVE History</a></li>
                            <li><a href="studentTerminatedHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> TERMINATED History</a></li>
                            <li><a href="studentDeletedHistory.jsp"> &nbsp; &bull; <i class="icon-th-large"></i> DELETED History</a></li>
                            <li class="nav-header">Function</li>
                            <li><a href="studentNewMissionRequestSubmission.jsp"><i class="icon-pencil"></i> New Mission Request</a></li>
                            <li class="active"><a href="#"> &nbsp; &bull; <i class="icon-white icon-tasks"></i> Complete the forms </a></li>
                            <li><a href="studentShowNewAdvanceCompensation.jsp"><i class="icon-pencil"></i> New Advance Compensation</a></li>
                            <li><a href="studentShowNewReimbursement.jsp"><i class="icon-pencil"></i> New Reimbursement</a></li>
                            <li class="divider"></li>
                            <li><a href="studentFAQ.jsp"><i class="icon-info-sign"></i> F.A.Q.</a></li>             
                        </ul>
                    </div><!--/.well -->
                </div><!--/span-->
                <div class="span9" style="margin-left: 26%;">
                    <form action="studentSubmitMissionRequest.jsp" method="post">
                        <div class="hero-unit">
                            <h1>New Mission Request</h1>                        
                        </div>
                        <div class="row-fluid">
                            <div class="row-fluid">
                                <div class="span5">
                                    <h2>
                                        Travel information:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Planned Destination *                                   
                                    </h4>
                                    <br/>
                                    <input name="destination" type="text" /> 
                                    <br />
                                    <br />
                                    <%
										Query q = new Query( "current_domicile", "students", "user_ID=" + a.getId().toString() );
										ResultSet stud = q.executeOnPhdDatabase();
										stud.next();
										String address = stud.getString( "current_domicile" );
                                    %>
                                    <h4>
                                        Current address *
                                    </h4>
                                    <br />
                                    <input name="currentAddress" type="text" value="<%=address%>"/>
                                    <br />
                                    <br />
                                    <h4>
                                        Number of nights *
                                    </h4>
                                    <br />
                                    <input name="nights" type="number" value="0" />
                                    <br />
                                    <br />
                                    <h4>
                                        Planned start date *
                                    </h4>
                                    <br />
                                    <input name="startDate" type="date" value="yyyy-mm-dd" />
                                    <br />
                                    <br />
                                    <h4>
                                        Planned end date *
                                    </h4>
                                    <br />
                                    <input name="endDate" type="date" value="yyyy-mm-dd" />
                                    <br />
                                    <br />  
                                    <h4>
                                        Reason for travel *
                                    </h4>
                                    <br />
                                    <textarea name="reason" cols="42" rows="8" ></textarea>
                                    <br />
                                    <br /> 
                                    <h4>
                                        Is a stopover requested during your trip? *
                                    </h4>
                                    <br />
                                    <input name="isStopover" type="radio" value="true" /> Yes
                                    <input name="isStopover" type="radio" value="false" /> No
                                    <br />
                                    <br /> 
                                    <h4>
                                        If yes, why? 
                                    </h4>
                                    <br />
                                    <textarea name="stopoverReason" cols="35" rows="2"></textarea>
                                    <br />
                                    <br /> 
                                </div> 
                                <div class="span5">
                                    <h2>
                                        Transportation:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Planned means of transport 
                                    </h4>
                                    <br />
                                    <textarea name="planned_means_of_transports" rows="4" cols="42"></textarea>
                                    <br />
                                    <br />
                                    <h4>
                                        Type of transportation *
                                    </h4>
                                    <br />
                                    <select name="typeOfTransportation" onclick="if(get)">
                                        <option value="BUSINESS">BUSINESS</option>
                                        <option value="ORDINARY">ORDINARY</option>
                                        <option value="EXTRAORDINARY">EXTRAORDINARY</option>
                                    </select>
                                    <br />
                                    <br />
                                    <h4>
                                        (Compile only if you are going with a private vehicle)<br />
                                        Model:
                                    </h4>
                                    <br />
                                    <input type="text" name="modelOfPrivateVehicle"/>
                                    <br />
                                    <br />
                                    <h4>
                                        License Plate
                                    </h4>
                                    <br />
                                    <input type="text" name="license_plate">
                                    <br />
                                    <br />
                                </div> 
                            </div>
                            <hr />
                            <div class="row-fluid">
                                <div class="span5">
                                    <h2>
                                        Funds information:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Are you going to use personal fund? *
                                    </h4>
                                    <br/>
                                    <input name="personalFund" type="radio" value="true" /> Yes
                                    <input name="personalFund" type="radio" value="false" /> No
                                    <br />
                                    <br />
                                    <h4>
                                        Are you going to use your external fund? *
                                    </h4>
                                    <br/>
                                    <input name="externalFund" type="radio" value="true" /> Yes
                                    <input name="externalFund" type="radio" value="false" /> No
                                    <br />
                                    <br />
                                    <h4>
                                        Define your extra fund name:
                                    </h4>
                                    <br/>
                                    <input name="secondFundName" type="text" value="" />
                                    <br />
                                    <br />
                                </div>
                                <div class="span5">
                                    <h2>
                                        Other information:
                                    </h2>
                                    <br />
                                    <br />
                                    <h4>
                                        Other declarations
                                    </h4>
                                    <br />
                                    <textarea name="otherDeclarations" cols="42" rows="8" ></textarea>
                                    <br />
                                    <br />
                                    <h4>
                                        (If you chose extraordinary type of transportation)<br />
                                        Reason for extraordinary transport
                                    </h4>
                                    <br />
                                    <textarea name="reasonExtraordinaryTransport" cols="42" rows="8"></textarea>
                                </div>                               
                            </div>
                        </div>
                        <hr />            
                        <div class="row-fluid">
                            <table>
                                <tr>                                                    
                                    <td>
                                        <a class="btn btn-primary" data-toggle="modal" href="#Submit" >Submit</a>    
                                        <!--MODAL che appare quando si clicca su Refuse-->
                                        <div class="modal hide fade" id="Submit">
                                            <div class="modal-header">
                                                <button class="close" data-dismiss="modal">x</button>
                                                <h3>Are You Sure?</h3>
                                            </div>
                                            <div class="modal-body">
                                                <p>Click "Save Changes" to SUBMIT the trip, Close instead.</p>
                                            </div>
                                            <div class="modal-footer">    
                                                <table>
                                                    <tr>                                                    
                                                        <td>
                                                            <button class="btn btn-primary btn-success">Save Changes</button>
                                                        </td>
                                                        <td>
                                                            <button class="btn" data-dismiss="modal">Close</button>
                                                        </td>
                                                    </tr>
                                                </table>  
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <button class="btn btn-primary" type="reset"  >Reset</button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </form>
                </div>                
            </div>
        </div><!--/.fluid-container-->
        <div class="navbarCC navbar-fixed-bottom">
            <div class="navbarCC-inner">
                <div class="container-fluid">				
                    <a class="brand" href="#">&copy; 2012 Startup</a>					
                </div>
            </div>
        </div>
		<!-- Il javascript -->
		<script src="js/jquery.js"></script>
		<script src="js/bootstrap.js"></script>
	</body>
</html>
<%
	}
	catch( SQLException sqlException )
	{
		sqlException = new SQLException( "The database is currently busy.<br />" +
										 "If the problem persists, please report it to the administration." );
		request.setAttribute( "exception", sqlException );
		request.getRequestDispatcher( "errorPage.jsp" ).forward( request, response );
	}
	catch( RuntimeException runtimeException )
	{
		if( runtimeException.getClass().equals( NullPointerException.class ) )
		{
			runtimeException = new NullPointerException( "The session has timed out:<br />" + "" +
														 "try reloading page.<br />" +
														 "If the problem persists, please report it to the administration." );
		}
		request.setAttribute( "exception", runtimeException );
		request.getRequestDispatcher( "errorPage.jsp" ).forward( request, response );
	}
%>